<template>
	<!-- 服务详情 -->
	<view>
		<!-- banner -->
		<u-swiper :list="db.images" circular height="320" mode="none"></u-swiper>
		<view class="detailed">
			<view>{{db.name}}</view>
			<view>
				<view>
					<text class="price">￥{{db.price}}</text>
					<text>/{{db.goods_format}}</text>
				</view>
				<text>已服务{{db.sells}}次</text>
			</view>
		</view>
		
		<!-- nav -->
		<!-- <view class="nav">
			<text v-for="(item,index) in nav" :key="index"
				:class="navActive == index?'active':''"
				@click="navActive = index"
			>{{item}}</text>
		</view> -->
		
		<!-- 详情 -->
		<view v-if="navActive == 0" v-html='db.content'></view>
		<!-- 评论 -->
		<view class="comment" v-if="navActive == 1">
			<view v-for="(item,index) in comment" :key="index">
				<image class="avatar" :src="item.avatar" mode="aspectFill"></image>
				<view class="cont">
					<view class="top">
						<text>{{item.name}}</text>
						<view>
							<text>{{item.time}}</text>
							<text v-if="item.evaluate == 0">差评</text>
							<text v-if="item.evaluate == 1">中评</text>
							<text v-if="item.evaluate == 2" style="color: #FA982D;">好评</text>
						</view>
					</view>
					<view class="msg">{{item.msg}}</view>
					<view class="images">
						<image v-for="(item,index) in item.images" :key="index" :src="item"></image>
					</view>
					<view class="serve">
						<image :src="item.serve.thumb" mode="widthFix"></image>
						<view>
							<view>{{item.serve.name}}</view>
							<text>{{item.serve.msg}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>
		
		<view class="submit" v-if="navActive == 0" @click="C_yuyue">立即预约</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				nav:['详情','评价'],
				navActive:0,
				comment:[],
				
				db:{}
			};
		},
		onLoad(o) {
			this.db = JSON.parse(decodeURIComponent(o.db))
		},
		onShow() {
			// this.def_database()
		},
		methods:{
			def_database(){
				let url = this.vuex_httpImageUrl
				this.comment = [
					{
						avatar:url+"static/index/test/thumb.png",
						name:'微信昵称',
						time:'2021-01-01',
						evaluate:2,  //0差评1中评2好评
						msg:'服务质量不错！服务质量不错！服务质量不错！服务质量不错！服务质量不错！',
						images:[
							url+"static/index/test/thumb.png",
							url+"static/index/test/thumb.png",
							url+"static/index/test/thumb.png",
							url+"static/index/test/thumb.png",
							url+"static/index/test/thumb.png",
							url+"static/index/test/thumb.png",
							url+"static/index/test/thumb.png",
							url+"static/index/test/thumb.png",
						],
						serve:{
							thumb:url+"static/index/test/thumb.png",
							name:'服务名称',
							msg:'单人局部按摩'
						}
					}
				]
			},
			C_yuyue(){
				this.$u.post('/local/addlocal',{
					appoint_time:parseInt(new Date().getTime()/1000),
					local_id:this.db.id
				}).then(res=>{
					console.log(res);
					this.$u.toast(res.msg)
				})
			}
		}
	}
</script>

<style lang="scss">
	.detailed{
		padding: 30rpx;
		background-color: #FFFFFF;
		>view{
			&:nth-child(1){
				font-size: 40rpx;
			}
			&:nth-child(2){
				display: flex;
				justify-content: space-between;
				margin-top: 20rpx;
				color: #ADADAD;
				.price{
					color: red;
					font-size: 40rpx;
					display: inline-block;
					margin-right: 10rpx;
					&::first-letter{
						font-size: 26rpx;
					}
				}
			}
		}
	}	
	
	.nav{
		width: 65%;
		margin: 30rpx auto;
		font-size: 35rpx;
		display: flex;
		justify-content: center;
		text{
			display: inline-block;
			text-align: center;
			width: 50%;
			&.active{
				font-weight: bold;
				position: relative;
				&::before{
					content: '';
					position: absolute;
					bottom: -18rpx;
					left: 39%;
					width: 50rpx;
					height: 10rpx;
					border-radius: 50rpx;
					background:linear-gradient(#3174E9,#3599EE);
					
				}
			}
		}
	}
	.comment{
		width: 95%;
		margin: auto;
		background-color: #FFFFFF;
		padding: 20rpx;
		box-sizing: border-box;
		border-radius: 20rpx;
		>view{
			display: flex;
			.avatar{
				width: 80rpx;
				height: 80rpx;
				border-radius: 50%;
				margin-right: 20rpx;
			}
			.cont{
				flex: 1;
				margin-top: 20rpx;
				>view{
					margin-bottom: 20rpx;
					&.top{
						display: flex;
						justify-content: space-between;
					}
					&.images{
						display: grid;
						grid-template-columns:repeat(4,1fr);
						grid-gap:20rpx;
						image{
							width: 120rpx;
							height: 120rpx;
							margin: auto;
						}
					}
					&.serve{
						display: flex;
						background-color: #F4F4F4;
						padding: 20rpx;
						image{
							width: 80rpx;
							height: 80rpx;
							border-radius: 10rpx;
							margin-right: 20rpx;
						}
						>view{
							flex: 1;
							display: flex;
							flex-direction: column;
							justify-content: space-between;
						}
					}
				}
				
			}
		}
	}
	
	.submit{
		width: 80%;
		padding: 20rpx;
		text-align: center;
	}
</style>
